/**
 * 
 */
package sopa.java.enums;

/**
 * @author Bulent
 * 
 */

import java.util.HashMap;
import java.util.Map;

public enum Enum1
{
    ABC("abc"), DEF("def"), XYZ("xyz");

    private final String name;

    private Enum1(String name)
    {
        this.name = name;
    }

    @Override
    public String toString()
    {
        return name;
    }

    private static final Map<String, Enum1> stringToEnum = new HashMap<String, Enum1>();
    static
    {
        for (Enum1 platform : values())
        {
            stringToEnum.put(platform.toString(), platform);
        }
    }

    /**
     * Returns Enum1 from string, or null if string is invalid.
     */
    public static Enum1 fromString(String platform)
    {
        return stringToEnum.get(platform);
    }
}

